unit USharedMemoryResvForm;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, UVRSharedMemory;

type
  TForm1 = class(TForm)
    edtHandle: TEdit;
    mmoLog: TMemo;
    btnResv: TButton;
    procedure FormCreate(Sender: TObject);
    procedure btnResvClick(Sender: TObject);
  private
    { Private declarations }
    procedure Resv(var Msg: TMessage);message $500;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  GSharedMemoryFactory: TVRSharedMemoryFactory;

implementation

uses UVRConsts;

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
  GSharedMemoryFactory := TVRSharedMemoryFactory.Create;
  edtHandle.Text := IntToStr(Self.Handle);
end;

procedure TForm1.Resv(var Msg: TMessage);
//var
//  buf: array[0..100] of Char;
begin
//  mmoLog.Lines.Add('Received: ' + string(buf));
  btnResv.Click;
end;

procedure TForm1.btnResvClick(Sender: TObject);
var
  mem: TVRSharedMemory;
  buf: array[0..100] of Char;
begin
  mem := GSharedMemoryFactory.GetSharedMemory(SVRBitmapBufferName);
  mem.Read(buf, 3);
//  mem.Seek(0, soFromBeginning);
  mmoLog.Lines.Add('Read: '  + buf);
//  PostMessage(StrToInt(edtHandle.Text), 1000, 0, 0);
end;

end.
